<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$title = "系统管理员 注销注单";
$ui = new UI();
include( "admin_menu.php" );
$conf = new Config();
if ($conf->get("calcbet") == 1)
{
    $ui->showErrorPage("<p class=error>已经在颁奖过帐中，无法取消注单！</p>");
    exit();
}
$todayOpen = date("Y-m-d");
$tblName = $g_gametype_3d[0]['ch'];
$reBetTotalFlag = false;
if ($curruser['acl'] == 255)
{
    $reBetTotalFlag = true;
}
if (isset($_GET['fineAccID']))
{
    $fineAcc = getvar("fineAcc");
    $sql = "SELECT id, acl FROM k_user WHERE account = '{$fineAcc}' AND acl between 1 AND 5 LIMIT 1";
    $rs = getdb($sql);
    if ($rs->eof)
    {
        echo "<p>查无该帐号资料!</p>";
    }
    else
    {
        $fineAccID = $rs->f['id'];
        $fineAccACL = $rs->f['acl'];
        $sql = "SELECT id, open, round FROM lotto where open = '{$todayOpen}' LIMIT 1";
        $rs = getdb($sql);
        if ($rs->eof)
        {
            $ui->showErrorPage("<p class=error>目前无{$tblName}可下注期数！</p>");
            exit();
        }
        $lotto_id = $rs->f['id'];
        $open = $rs->f['open'];
        $round = $rs->f['round'];
        $bettypesubid = getvar("bettypesubid");
        $betname = $g_betname;
        if ($bettypesubid != "" && $bettypesubid != 0 - 1)
        {
            $bettypesubidStr = " AND bettype = {$bettypesubid} ";
            $titleStr = $betname[$bettypesubid];
        }
        else
        {
            $bettypesubidStr = "";
            $titleStr = "";
        }
        $sql = "SELECT * FROM bet" . ( $fineAccACL == 1 ? "" : "2" ) . " WHERE user_id = {$fineAccID} AND lotto_id = {$lotto_id} AND rame IN (0,2) {$bettypesubidStr}";
        $page = intval(getvar("page"));
        if (!$page)
        {
            $page = 1;
        }
        $rs = getdb($sql, $page, 10);
        echo "<form method='post' action='op.php?op=admin&fp=delbet1&gametype=0' onsubmit='return confirm(\"确定要取消勾选的注单吗?\")'>";
        echo "<input type='hidden' name='bet' value='" . ( $fineAccACL == 1 ? "1" : "2" ) . "' />";
        echo "<table class='tblMy3D' id='tblFineID'>";
        echo "<tr class=\"paperAll\"><td colspan='12'>第{$round}期 {$open} ";
        echo "帐号: {$fineAcc}";
        if ($fineAccACL == 1)
        {
            echo "<strong>会员下注注单</strong>";
        }
        else
        {
            echo "<strong>管理走飞注单</strong>";
        }
        if ($titleStr)
        {
            echo " 【查询玩法: {$titleStr}】";
        }
        echo " </td></tr>";
        if ($rs->eof)
        {
            echo "<tr><td class=\"msgBox-yellow\" colspan=\"12\">查无【六合彩】可取消注单</td></tr>";
        }
        else
        {
            echo "<tr class=\"paperAll\" align=center><td>勾</td><td nowrap>单号 / 时间</td><td nowrap>会员 / 退水</td><td nowrap>下注玩法</td><td nowrap>盘类 / 期数 / 开奖日期</td><td nowrap>下注内容</td><td nowrap>下注金额</td><td nowrap>赔率</td><td nowrap>备注</td><td nowrap>IP</td></tr>";
            $rateNum = 3;
            $littleNum = 0;
            $littleAmount = 0;
            $littleBack = 0;
            $littleB1 = 0;
            $backType = "back" . $fineAccACL;
            $backRsType = "a" . $fineAccACL;
            $backRsTypeB = "b" . $fineAccACL;
            while (!$rs->eof)
            {
                echo "<tr class=\"td2\">";
                if ($rs->f['rame'] == 2)
                {
                    echo "<td align='center'>--</td>";
                }
                else
                {
                    echo "<td><input type='checkbox' name='id[]' value='" . $rs->f['id'] . "' /></td>";
                }
                echo "<td nowrap><font color=\"green\">" . $rs->f['id'] . "</font>&nbsp;&nbsp;" . date("m-d H:i:s", $rs->f['createtime']) . "</td>";
                echo "<td nowrap>{$fineAcc}&nbsp;&nbsp;<font color=\"green\">" . round(100 - $backType, 2) . "</font></td>";
                echo "<td nowrap class=\"paper" . $g_gametype_3d[$gametype]['en'] . "\">" . $g_gametype_3d[$gametype]['ch'] . "</td>";
                if ($fineAccACL == 1)
                {
                    echo "<td nowrap>" . $g_disk_name[$rs->f['disk']] . "&nbsp;/&nbsp;";
                }
                else
                {
                    echo "<td nowrap>&nbsp;";
                }
                echo "{$round}期&nbsp;<font color=\"green\">{$open}</font></td>";
                echo "<td nowrap>" . GetBetContent($rs->f['bettype'], $rs->f['numbers'], $rs->f['amount']) . "</td>";
                if (20000 < $rs->f['amount'])
                {
                    $color = "alert2";
                }
                else if (10000 < $rs->f['amount'])
                {
                    $color = "alert1";
                }
                else
                {
                    $color = "";
                }
                echo "<td nowrap align=\"right\" class=\"" . $color . "\">" . $rs->f['amount'] . "</td>";
                echo "<td nowrap align=\"right\">" . floatval(show_rate($rs->f['bettype'], $rs->f['rate'] - 0)) . "</td>";
                if ($rs->f['rame'] == 1)
                {
                    $note = "<font color=red>- 逾时 -</td>";
                }
                else if ($rs->f['rame'] == 2)
                {
                    $note = "<font color=red>- 取消 -</td>";
                }
                else if ($rs->f['rame'] == 3)
                {
                    $note = "<font color=red>- 异常 -</td>";
                }
                else
                {
                    $note = "";
                    $littleNum += 1;
                    $littleAmount += $rs->f['amount'];
                    $littleBack += $rs->f[$backRsType];
                    $littleB1 += $rs->f[$backRsTypeB];
                }
                echo "<td nowrap>" . $note . "</td>";
                echo "<td nowrap>" . $rs->f['ip'] . "</td>";
                echo "</tr>";
                $rs->movenext();
            }
            $totalrecords = 0;
            $totalAmount = 0;
            $totalA1 = 0;
            $totalB1 = 0;
            echo "<tr><td class=\"msgBox-yellow\" colspan=\"12\"><input type=\"submit\" value=\"确定取消\" />";
            echo "<input type=button name='reset' value='回取消页面' onclick=\"location.href='op.php?op=admin&fp=delbet1&gametype={$gametype}'\">";
            echo "</td></tr>";
            echo "<tr><td class=\"paperAll\" colspan=\"12\">" . $rs->pagelink() . "</td></tr>";
        }
        echo "</table>";
        echo "</form>";
        echo " <script>";
        echo " $(document).ready(function() {";
        echo " $('#tblFineID tr')";
        echo " .filter(':has(:checkbox:checked)')";
        echo " .addClass('td17')";
        echo " .end()";
        echo "  .click(function(event) {";
        echo " $(this).toggleClass('td17');";
        echo " if (event.target.type !== 'checkbox') {";
        echo " $(':checkbox', this).attr('checked', function() {";
        echo " return !this.checked;";
        echo " });";
        echo " }";
        echo " });";
        echo " });</script> ";
    }
    echo "<input type=button name='reset' value='回取消页面' onclick=\"location.href='op.php?op=admin&fp=delbet1&gametype={$gametype}'\">";
}
else if ($reBetTotalFlag && isset($_POST['betReflashByLottoIdFlag']))
{
    include_once( "class_6h/class.lotto6h.php" );
    $Lotto6hClass = new lotto6h();
    $LottoID = intval($_POST['lottoId']);
    if (0 < $LottoID)
    {
        echo "<br><ul>";
        echo "<p><li>系统维护启动中... </li></p>";
        $conf->set("systemcheck_6h", 1);
        $ps = 0;
        $k = 1;
        while ($k <= 600)
        {
            ++$ps;
            ++$k;
        }
        echo "<br><p><li>注单重整中  请稍候... </li></p>";
        $Lotto6hClass->ReBetTotalByLottoId($LottoID);
        $conf->set("systemcheck_6h", 0);
        echo "<br><p><li>注单重整完成，系统维护关闭！</li></p>";
        echo "</ul>";
    }
}
else if (isset($_POST['id']))
{
    include_once( "class_6h/class.lotto6h.php" );
    $Lotto6hClass = new lotto6h();
    $bet = intval($_POST['bet']);
    $betname = "";
    if ($bet == 1)
    {
        $betfile = "bet";
        $betname = "会员注单";
    }
    else if ($bet == 2)
    {
        $betfile = "bet2";
        $betname = "下线走飞注单";
    }
    else if ($bet == 3)
    {
        $betfile = "bet8";
        $betname = "公司走飞注单";
    }
    else if ($bet == 4)
    {
        $betfile = "bet_all";
        $betname = "管理层全部注单";
    }
    else
    {
        $ui->showErrorPage("请选择注单类型！");
        exit();
    }
    if ($betfile == "bet_all")
    {
        $id = getvar("id");
        $rs = getdb("select id,acl from k_user where account='" . $id . "'");
        if ($rs->eof)
        {
            $ui->showErrorPage("错误的会员帐号！");
            exit();
        }
        $userid = $rs->f['id'];
        $acl = $rs->f['acl'];
        if ($acl == 1)
        {
            $userlist = $userid;
        }
        else
        {
            $userlist = GetUserList($userid);
            if ($userlist == "")
            {
                $ui->showErrorPage("没有会员！");
                exit();
            }
        }
        $rs = getdb("select id,open,round from lotto where open>='" . date("Y-m-d") . "' order by open LIMIT 1");
        if ($rs->eof)
        {
            $ui->showErrorPage("没有建立期数！");
            exit();
        }
        $lotto_id = $rs->f['id'];
        $open = $rs->f['open'];
        $round = $rs->f['round'];
        $rs->close();
        $rs = getdb("select count(id) from bet where lotto_id=" . $lotto_id . " and user_id in (" . $userlist . ")");
        if ($rs->f[0] == 0)
        {
            $ui->showErrorPage("没有任何注单！");
            exit();
        }
        $betcount = $rs->f[0];
        if (isset($_POST['ok']))
        {
            $tmpArr = array(7, 8, 9, 10, 11, 29, 27, 32, 33, 36, 39, 40, 41, 42, 43, 44, 45);
            getdb("update bet set rame=2, state=0 where lotto_id={$lotto_id} and user_id in ({$userlist}) and rame=0");
            $updateId = getdb("!!select id,bettype from bet where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist})");
            while (!$updateId->eof)
            {
                $btype = intval($updateId->f[1]);
                if (!in_array($btype, $tmpArr))
                {
                    $Lotto6hClass->getBet_6h($updateId->f[0]);
                }
                $updateId->next();
            }
            if (1 < $acl)
            {
                getdb("update bet2 set rame=2, state=0 where lotto_id=" . $lotto_id . " and user_id=" . $userid . " and rame=0");
                $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id=" . $userid);
                while (!$updateId->eof)
                {
                    $btype = intval($updateId->f[1]);
                    if (!in_array($btype, $tmpArr))
                    {
                        $Lotto6hClass->getBet2_6h($updateId->f[0]);
                    }
                    $updateId->next();
                }
                if ($acl == 3)
                {
                    $userlist2 = GetUserList($userid, 2);
                    if ($userlist2 != "")
                    {
                        getdb("update bet2 set rame=2, state=0 where lotto_id={$lotto_id} and user_id in ({$userlist2}) and rame=0");
                        $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist2})");
                        while (!$updateId->eof)
                        {
                            $btype = intval($updateId->f[1]);
                            if (!in_array($btype, $tmpArr))
                            {
                                $Lotto6hClass->getBet2_6h($updateId->f[0]);
                            }
                            $updateId->next();
                        }
                    }
                }
                else if ($acl == 4)
                {
                    $userlist2 = GetUserList($userid, 2);
                    $userlist3 = GetUserList($userid, 3);
                    if ($userlist2 != "")
                    {
                        getdb("update bet2 set rame=2, state=0 where lotto_id=" . $lotto_id . " and user_id in (" . $userlist2 . ") and rame=0");
                        $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist2})");
                        while (!$updateId->eof)
                        {
                            $btype = intval($updateId->f[1]);
                            if (!in_array($btype, $tmpArr))
                            {
                                $Lotto6hClass->getBet2_6h($updateId->f[0]);
                            }
                            $updateId->next();
                        }
                    }
                    if ($userlist3 != "")
                    {
                        getdb("update bet2 set rame=2, state=0 where lotto_id=" . $lotto_id . " and user_id in (" . $userlist3 . ") and rame=0");
                        $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist3})");
                        while (!$updateId->eof)
                        {
                            $btype = intval($updateId->f[1]);
                            if (!in_array($btype, $tmpArr))
                            {
                                $Lotto6hClass->getBet2_6h($updateId->f[0]);
                            }
                            $updateId->next();
                        }
                    }
                }
                else if ($acl == 5)
                {
                    $userlist2 = GetUserList($userid, 2);
                    $userlist3 = GetUserList($userid, 3);
                    $userlist4 = GetUserList($userid, 4);
                    if ($userlist2 != "")
                    {
                        getdb("update bet2 set rame=2, state=0 where lotto_id=" . $lotto_id . " and user_id in (" . $userlist2 . ") and rame=0");
                        $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist2})");
                        while (!$updateId->eof)
                        {
                            $btype = intval($updateId->f[1]);
                            if (!in_array($btype, $tmpArr))
                            {
                                echo "<br/>---" . $btype . "---<br/>";
                                $Lotto6hClass->getBet2_6h($updateId->f[0]);
                            }
                            $updateId->next();
                        }
                    }
                    if ($userlist3 != "")
                    {
                        getdb("update bet2 set rame=2, state=0 where lotto_id={$lotto_id} and user_id in ({$userlist3}) and rame=0");
                        $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist3})");
                        while (!$updateId->eof)
                        {
                            $btype = intval($updateId->f[1]);
                            if (!in_array($btype, $tmpArr))
                            {
                                $Lotto6hClass->getBet2_6h($updateId->f[0]);
                            }
                            $updateId->next();
                        }
                    }
                    if ($userlist4 != "")
                    {
                        getdb("update bet2 set rame=2, state=0 where lotto_id=" . $lotto_id . " and user_id in (" . $userlist4 . ") and rame=0");
                        $updateId = getdb("!!select id,bettype from bet2 where lotto_id={$lotto_id} and rame=2 and state=0 and user_id in ({$userlist4})");
                    }
                    while (!$updateId->eof)
                    {
                        $btype = intval($updateId->f[1]);
                        if (!in_array($btype, $tmpArr))
                        {
                            $Lotto6hClass->getBet2_6h($updateId->f[0]);
                        }
                        $updateId->next();
                    }
                }
            }
            echo "<p>注单全部取消完成!</p>";
        }
        else
        {
            $name = "会员";
            if ($acl == 2)
            {
                $name = "代理";
            }
            else if ($acl == 3)
            {
                $name = "总代理";
            }
            else if ($acl == 4)
            {
                $name = "股东";
            }
            else if ($acl == 5)
            {
                $name = "大股东";
            }
            echo "<form action=\"op.php?op=admin&fp=delbet1\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
            echo "<table border=1 cellpadding=3 cellspacing=0>";
            echo "<tr><td class=td0>期数<td>";
            echo d3($round) . " 期 <font color=#217952>" . $open . "</font>";
            echo "<tr><td class=td0>会员下注笔数<td  align=right>" . $betcount . "</table>";
            echo "<p>确定取消这位" . $name . " " . $id . "所属全部会员的注单？</p>";
            echo "<input type=hidden name=id value={$id}>";
            echo "<input type=hidden name=bet value={$bet}>";
            echo "<input type=hidden name=ok value=1>";
            echo "<p><input type=submit value=确定> <input type=button value=放弃 onclick=\"location.href='op.php?op=admin&fp=delbet1'\">";
            echo "</form>";
        }
    }
    else
    {
        $rs = getdb("select id,open,round from lotto where open>='" . date("Y-m-d") . "' order by open LIMIT 1");
        if ($rs->eof)
        {
            $ui->showErrorPage("没有建立期数！");
            exit();
        }
        $lotto_id = $rs->f['id'];
        $rs->close();
        $tmpArr = array(7, 8, 9, 10, 11, 29, 27, 32, 33, 36, 40, 41, 42, 43, 44, 45);
        if (is_array($_POST['id']))
        {
            $id = implode(",", $_POST['id']);
        }
        else
        {
            $id = $_POST['id'];
        }
        if (strchr($id, ","))
        {
            $rs = getdb("!!select * from " . $betfile . " where id in (" . $id . ") and lotto_id=" . $lotto_id);
            if ($rs->eof)
            {
                $ui->showErrorPage("错误的注单编号群组！");
                exit();
            }
            if (0 < $rs->f['rame'] && $rs->f['rame'] != 2 && $betfile != "bet8")
            {
                $ui->showErrorPage("已经颁奖完毕注单无法取消！");
                exit();
            }
            if ($rs->f['rame'] == 2)
            {
                $ui->showErrorPage("已经是被取消的注单群组！");
                exit();
            }
            if (isset($_POST['ok']))
            {
                getdb("update " . $betfile . " set rame=2,state=0,r5=0 where id in (" . $id . ") and rame=0 and lotto_id=" . $lotto_id);
                $updateId = getdb("!!select id,bettype from {$betfile} where rame=2 and id in ({$id}) and lotto_id=" . $lotto_id);
                while (!$updateId->eof)
                {
                    $btype = intval($updateId->f[1]);
                    if (!in_array($btype, $tmpArr))
                    {
                        switch ($betfile)
                        {
                            case "bet" :
                                $Lotto6hClass->getBet_6h($updateId->f[0]);
                                break;
                            case "bet2" :
                                $Lotto6hClass->getBet2_6h($updateId->f[0]);
                                break;
                            case "bet8" :
                                $Lotto6hClass->getBet8_6h($updateId->f[0]);
                                break;
                        }
                    }
                    $updateId->next();
                }
                echo "<p>注单取消完成!</p>";
            }
            else
            {
                echo "<form action=\"op.php?op=admin&fp=delbet1\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
                echo "<table border=1 cellpadding=3 cellspacing=0>";
                echo "<tr class=td2><td class=td0 colspan='2'><b>" . $betname . " 取消</b>";
                echo "<tr class=td2><td class=td0>注单编号群<td>" . $id;
                echo "<tr class=td2><td class=td0>时间<td>" . date("m-d H:i:s", $rs->f['createtime']);
                echo "<tr class=td2><td class=td0>期数<td>";
                $lotto = new lotto($rs->f['lotto_id']);
                echo d3($lotto->data['round']) . " 期 <font color=#217952>" . $lotto->data['open'] . "</font>";
                $stopbet = $conf->get("waitbet");
                $t = $lotto->data['open'] . " " . substr($stopbet, 0, 2) . ":" . substr($stopbet, 2);
                $t = strtotime($t);
                $n = $lotto->data['n1'] + $lotto->data['n2'] + $lotto->data['n3'] + $lotto->data['n4'] + $lotto->data['n5'] + $lotto->data['n6'] + $lotto->data['spec'];
                if ($conf->get("calcbet") == 1)
                {
                    echo "<p><font color=red>已经在颁奖过帐中，注单无法取消！</font></p>";
                }
                else if (( $t <= systime() || 0 < $n ) && $betfile != "bet8")
                {
                    echo "<p><font color=red>超过截止下注时间，该笔注单无法取消！</font></p>";
                }
                else
                {
                    echo "<p>确定取消这些 " . $betname . "群组？</p>";
                    echo "<input type=hidden name=id value={$id}>";
                    echo "<input type=hidden name=bet value={$bet}>";
                    echo "<input type=hidden name=ok value=1>";
                    echo "<p><input type=submit value=确定> <input type=button value=放弃 onclick=\"location.href='op.php?op=admin&fp=delbet1'\">";
                }
                echo "</form>";
            }
        }
        else
        {
            $id = intval($id);
            if ($id == 0)
            {
                $ui->showErrorPage("错误的注单编号！");
                exit();
            }
            $rs = getdb("!!select * from " . $betfile . " where id=" . $id . " and lotto_id=" . $lotto_id);
            if ($rs->eof)
            {
                $ui->showErrorPage("错误的注单编号！");
                exit();
            }
            if (0 < $rs->f['rame'] && $rs->f['rame'] != 2 && $betfile != "bet8")
            {
                $ui->showErrorPage("已经颁奖完毕注单无法取消！");
                exit();
            }
            if ($rs->f['rame'] == 2)
            {
                $ui->showErrorPage("已经是被取消的注单！");
                exit();
            }
            if (isset($_POST['ok']))
            {
                if (0 < $rs->f['rame'] && $rs->f['rame'] != 2 && $betfile != "bet8")
                {
                    echo "已经颁奖完毕注单无法取消！";
                }
                else
                {
                    if ($rs->f['rame'] == 2)
                    {
                        echo "已经是被取消的注单！";
                    }
                    else
                    {
                        getdb("update {$betfile} set rame=2,state=0,r5=0 where id={$id} and rame=0 and lotto_id=" . $lotto_id);
                        $updateId = getdb("!!select id,bettype from {$betfile} where id={$id} and rame=2 and state=0 and lotto_id=" . $lotto_id);
                        while (!$updateId->eof)
                        {
                            $btype = intval($updateId->f[1]);
                            if (!in_array($btype, $tmpArr))
                            {
                                switch ($betfile)
                                {
                                    case "bet" :
                                        $Lotto6hClass->getBet_6h($updateId->f[0]);
                                        break;
                                    case "bet2" :
                                        $Lotto6hClass->getBet2_6h($updateId->f[0]);
                                        break;
                                    case "bet8" :
                                        $Lotto6hClass->getBet8_6h($updateId->f[0]);
                                        break;
                                }
                            }
                            $updateId->next();
                        }
                        echo "<p>注单取消完成!</p>";
                    }
                }
            }
            else
            {
                echo "<form action=\"op.php?op=admin&fp=delbet1\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
                echo "<table border=1 cellpadding=3 cellspacing=0>";
                echo "<tr class=td2><td class=td0 colspan=2><b>{$betname} 取消</b>";
                echo "<tr class=td2><td class=td0>注单编号<td>{$id}";
                if ($bet < 3)
                {
                    $u = get_user($rs->f['user_id']);
                    if ($bet == 1)
                    {
                        echo "<tr class=td2><td class=td0>会员帐号<td>" . $u['account'];
                    }
                    else
                    {
                        $acl = $u['acl'];
                        $name = "";
                        if ($acl == 2)
                        {
                            $name = "代理";
                        }
                        else if ($acl == 3)
                        {
                            $name = "总代理";
                        }
                        else if ($acl == 4)
                        {
                            $name = "股东";
                        }
                        else if ($acl == 5)
                        {
                            $name = "大股东";
                        }
                        echo "<tr class=td2><td class=td0>{$name}帐号<td>" . $u['account'];
                    }
                }
                echo "<tr class=td2><td class=td0>时间<td>" . date("m-d H:i:s", $rs->f['createtime']);
                echo "<tr class=td2><td class=td0>期数<td>";
                $lotto = new lotto($rs->f['lotto_id']);
                echo d3($lotto->data['round']) . " 期 <font color=#217952>" . $lotto->data['open'] . "</font>";
                echo "<tr class=td2><td class=td0>注单内容<td>" . GetBetContent($rs->f['bettype'], $rs->f['numbers'], $rs->f['amount']);
                echo "<tr class=td2><td class=td0>赔率<td>" . show_rate($rs->f['bettype'], $rs->f['rate']);
                echo "<tr class=td2><td class=td0>退水<td>" . $rs->f['back'];
                echo "<tr class=td2><td class=td0>金额<td>" . $rs->f['amount'];
                echo "</table>";
                $stopbet = $conf->get("waitbet");
                $t = $lotto->data['open'] . " " . substr($stopbet, 0, 2) . ":" . substr($stopbet, 2);
                $t = strtotime($t);
                $n = $lotto->data['n1'] + $lotto->data['n2'] + $lotto->data['n3'] + $lotto->data['n4'] + $lotto->data['n5'] + $lotto->data['n6'] + $lotto->data['spec'];
                if ($conf->get("calcbet") == 1)
                {
                    echo "<p><font color=red>已经在颁奖过帐中，注单无法取消！</font></p>";
                }
                else if (( $t <= systime() || 0 < $n ) && $betfile != "bet8")
                {
                    echo "<p><font color=red>超过截止下注时间，该笔注单无法取消！</font></p>";
                }
                else
                {
                    echo "<p><font color=red>！如果已颁奖完毕,取消注单後请重新颁奖！</font></p>";
                    echo "<p>确定取消这笔 " . $betname . "？</p>";
                    echo "<input type=hidden name=id value={$id}>";
                    echo "<input type=hidden name=bet value={$bet}>";
                    echo "<input type=hidden name=ok value=1>";
                    echo "<p><input type=submit value=确定> <input type=button value=放弃 onclick=\"location.href='op.php?op=admin&fp=delbet1'\">";
                }
                echo "</form>";
            }
        }
    }
}
else
{
    echo "<font color=red><b>注单取消</b></font><br>";
    echo "<form action=\"op.php?op=admin&fp=delbet1\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
    echo "<input type=radio name=bet value=1 checked>会员注单&#12288;<input type=radio name=bet value=2>下线走飞注单&#12288;<input type=radio name=bet value=3>公司走飞注单&#12288;<input type=radio name=bet value=4>管理层全部注单<br><br>";
    echo "请输入注单编号：<input name=id>";
    echo "<input type=submit value=确定>";
    echo "</form>";
    $sql = "SELECT id, open, round FROM lotto where open = '{$todayOpen}' LIMIT 1";
    $rs = getdb($sql);
    if (!$rs->eof)
    {
        echo "<form method='get' action='op.php' >";
        echo "<input type='hidden' name='op' value='admin' />";
        echo "<input type='hidden' name='fp' value='delbet1' />";
        echo "<input type='hidden' name='gametype' value='0' />";
        echo "<fieldset class='td2'><legend class='bgImg_{$gametype}' style='padding:5px;'>指定帐号勾选取消 六合彩 注单 </legend>";
        echo "<div>第" . $rs->f['round'] . "期 " . $rs->f['open'];
        echo "<div>";
        echo "请输入(会员/管理层 )帐号: <input type='text' name='fineAcc' />";
        $betname = $g_betname;
        echo "<select name='bettypesubid'>";
        echo "<option value='-1'>不限类别</option>";
        foreach ($betname as $betnameKey => $betnameVal)
        {
            echo "<option value='{$betnameKey}'>{$betnameVal}</option>";
        }
        echo "</select>";
        echo "<input type='submit' value='查询' />";
        echo "<input type='hidden' name='fineAccID' value='1' />";
        echo "</div>";
    }
    echo "<div>1) 已颁奖之注单无法取消。</div>";
    echo "<div>2) 会员帐号列出下注注单、管理层帐号列出走飞注单。</div>";
    echo "</fieldset>";
    echo "</form>";
    if ($reBetTotalFlag)
    {
        echo "<form action=\"op.php?op=admin&fp=delbet1\" method=\"post\" >";
        echo " <fieldset>\n\t\t<legend>六合 注单全部重新整理(指定期数)</legend>\n\t\t";
        $sql = "SELECT id,open,round,(SELECT COUNT(*) FROM bet WHERE lotto_id=lotto.id)/4800 as mins FROM lotto WHERE open != '0000-00-00' HAVING mins>0 ORDER BY id DESC LIMIT 0,5";
        $rs = getdb($sql);
        if (!$rs->eof)
        {
            echo "<select name=\"lottoId\">";
            while (!$rs->eof)
            {
                echo "<option value=\"" . $rs->f['id'] . "\">第" . $rs->f['round'] . "期 " . $rs->f['open'] . " ,预估需耗时: " . round($rs->f['mins'], 1) . " (分)</option>";
                $rs->next();
            }
            echo "</select>";
            echo "&nbsp;<input type=\"submit\" value=\"注单重整\" />";
            echo "<input type=\"hidden\" name=\"betReflashByLottoIdFlag\" value=\"1\" />";
            echo "<input type=hidden name=gametype value=0>";
            echo "<ul style=\"color:red;\">※注意：重整期间务必开启 六合系统维护。\n\t\t\t<li>重整时自动赔率将重新计算，预估耗用时间会因注单笔数、设备、网速之不同而有差异，所列时间仅供参考！</li>\n\t\t\t<li>重整时自动走飞将以目前最新赔率及走飞限额为计算依据，如果已颁奖请重新颁奖。</li>\n\t\t\t</ul>";
        }
        else
        {
            echo "<p>无任何{$tblName}期数</p>";
        }
        echo "</fieldset>";
        echo "</form>";
    }
}
?>